home *** CD-ROM | disk | FTP | other *** search
- PROGRAM Print_Source;
- { This program prints the Pascal source code from the Personal Pascal }
- { Manager instead of going back to the Desk Top. Additional, you can }
- { format a disk(single and double sided),delete,rename, and copy a file }
- { Written by Dan McKee, Compuserve - 75766,1515, Delphi - elmac }
- CONST
- three = 3;
- pattern = '.';
- blank = ' ';
- chunk_size = 4096;
- fn_length = 64;
- a_path = 'A:\';
- b_path = 'B:\';
-
- {$I GEMCONST.PAS}
-
- TYPE
-
- buffer_type = PACKED ARRAY[1..chunk_size] OF byte;
- file_name_type = packed array[1..80] of char;
- {$I GEMTYPE.PAS}
-
- VAR
- Path,fname : string;
- msg : Message_Buffer;
- menu : Menu_Ptr;
- Author_Box,Print_Box,Help_Box,drive_box,format_box,rename_box,delete_box
- ,copy_box,dos_box : Dialog_Ptr;
- dummy,file_title,open_item,print_item,help_title,Author_Item,ok_button,
- help_item, quit_item,sf,show_it,pushed,h_i,get_file,cancel_button,ss_btn,
- ds_btn,f_i,d_i,A_btn,B_btn,format_btn,format_item,copy_item,delete_item,
- rename_item,i,choice,r_i,e_i,c_i,ce_i,dos_item
- : integer;
- b : boolean;
- buf : buffer_type;
- in_file, out_file,p,nb : integer;
- name : file_name_type;
- filler : str255;
-
- {$I GEMSUBS.PAS}
-
-
-
- FUNCTION gem_create( VAR fname : file_name_type; mode : integer):integer;
- GEMDOS($3C);
-
- FUNCTION gem_open( VAR fname : file_name_type;mode : integer) :integer;
- GEMDOS($3D);
-
- PROCEDURE gem_close(handle : integer);
- GEMDOS($3E);
-
- FUNCTION gem_read(handle : integer ; nbytes : long_integer;
- VAR buf : buffer_type) : long_integer;
- GEMDOS($3F);
-
- FUNCTION gem_write(handle : integer ; nbytes : long_integer ;
- VAR buff : buffer_type): long_integer;
- GEMDOS($40);
-
-
-
- PROCEDURE gem_seek(nbytes : long_integer;handle,mode : integer);
- GEMDOS($42);
-
- FUNCTION Open_file( var name : path_name; mode : integer) : integer;
- GEMDOS($3D);
-
- FUNCTION Delete_File(var name : file_name_type ) : integer ;
- GEMDOS($41);
-
- PROCEDURE Do_Format ; FORWARD;
-
- PROCEDURE Format_Floppy(buffer,filler : long_integer;dev,spt,track,side,
- interleave : integer;magic : long_integer;virgin : integer);
- XBIOS(10);
-
- FUNCTION Boot_Sector(buff,serialno : long_integer;disktype,execflag :
- integer) : integer;
- XBIOS(18);
-
- FUNCTION Write_Sector(buff,filler : long_integer;dev,sector,track,side,count :
- integer) : integer;
- XBIOS(9);
-
- FUNCTION Rename_File(zero : integer ; var old_name,name :file_name_type)
- : integer;
- GEMDOS($56);
-
-
- PROCEDURE Copy_Dialog;
-
- BEGIN
- sf := system_font;
- copy_box := New_Dialog(5,0,0,30,11);
- ce_i := Add_DItem(copy_box,G_FText,Editable,
- 2,4,12,2,0,$1180);
-
- Set_DEdit(copy_box,ce_i,'________.___','aFFFFFFFFFF',''
- ,sf,TE_Left);
- c_i := Add_DItem(copy_box,G_Text,None,2,1,13,1,0,$1180);
- Set_DText(copy_box,c_i,'COPYING...',sf, TE_Center);
- c_i := Add_DItem(copy_box,G_Text,None,2,3,15,1,0,$1180);
- Set_DText(copy_box,c_i,fname,sf,TE_Center);
- a_btn := Add_DItem(copy_box,G_Button,Selectable|Radio_Btn,
- 2,6,8,1,1,$1180);
- Set_DText(copy_box,a_btn,'A',sf,TE_Center);
- b_btn := Add_DItem(copy_box,G_Button,Selectable|Radio_Btn,
- 15,6,8,1,1,$1180);
- Set_DText(copy_box,b_btn,'B',sf,TE_Center);
- ok_button := Add_DItem(copy_box,G_Button,Selectable|Exit_Btn,
- 2,8,8,2,2,$1180);
- Set_DText(copy_box,ok_button,'OK',sf,TE_Center);
- cancel_button := Add_DItem(copy_box,G_Button,Selectable|Exit_Btn
- ,15,8,8,2,2,$1180);
- Set_DText(copy_box,cancel_button,'CANCEL',sf,TE_Center);
- Obj_SetState(copy_box,a_btn,Selected,false);
- Center_Dialog(copy_box);
- show_it := Do_Dialog(copy_box,1);
- Get_DEdit(copy_box,ce_i,filler);
- End_Dialog(copy_box);
- END;{Copy_Dialog}
-
- PROCEDURE D_Dialog( fname : string);
-
- BEGIN
- sf := System_Font;
- delete_box := New_Dialog(4,0,0,30,10);
- d_i := Add_DItem(delete_box,G_Text,None,2,1,12,1,0,$1180);
- Set_DText(delete_box,d_i,'DELETE FILE',sf,TE_Center);
- d_i := Add_DItem(delete_box,G_Text,None,2,3,15,1,0,$1180);
- Set_Dtext(delete_box,d_i,fname,sf,TE_Center);
- ok_button := Add_DItem(delete_box,G_Button,Selectable|Exit_Btn,
- 2,7,8,2,2,$1180);
- Set_DText(delete_box,ok_button,'OK',sf,TE_Center);
- cancel_button := Add_DItem(delete_box,G_Button,Selectable|Exit_Btn,
- 15,7,8,2,2,$1180);
- Set_Dtext(delete_box,cancel_button,'CANCEL',sf,TE_Center);
- Center_Dialog(delete_box);
- show_it := Do_Dialog(delete_box,0);
- End_Dialog(delete_box);
- END; {Delete_Dialog}
-
- PROCEDURE Rename_Dialog( var name : str255);
-
- BEGIN
- sf := System_Font;
- rename_box := New_Dialog(4,0,0,30,10);
- e_i := Add_DItem(rename_box,G_FText,Editable,
- 2,4,12,2,0,$1180);
- Set_DEdit(rename_box,e_i,'________.___','aFFFFFFFFFF',name,
- sf,TE_Left);
- r_i := Add_DItem(rename_box,G_Text,None,2,1,13,1,0,$1180);
- Set_DText(rename_box,r_i,'RENAME FILE',sf,TE_Left);
- ok_button := Add_DItem(rename_box,G_Button,Selectable|Exit_Btn,
- 2,7,8,2,2,$1180);
- Set_DText(rename_box,ok_button,'OK',sf,TE_Center);
- cancel_button := Add_DItem(rename_box,G_Button,Selectable|Exit_Btn,
- 15,7,8,2,2,$1180);
- Set_DText(rename_box,cancel_button,'CANCEL',sf,TE_Center);
- Center_Dialog(rename_box);
- show_it := Do_Dialog(rename_box,1);
- Get_DEdit(rename_box,e_i,name);
-
- End_Dialog(rename_box);
- END; { Rename_Dialog }
-
- { Dialog box for printing a file or cancel printing }
- PROCEDURE Print_Info;
-
- BEGIN
- sf := System_Font;
- Print_Box := New_Dialog(15,0,0,40,9);
- Print_Item := Add_DItem(Print_Box,G_Text,None,2,1,36,1,0,$1180);
- Set_DText(Print_Box,Print_Item,'Printing....',sf,TE_Center);
- Print_Item := Add_DItem(Print_Box,G_Text,None,2,3,36,1,0,$1180);
- SET_DText(Print_Box,Print_Item,Name,sf,TE_Center);
- ok_button := Add_DItem(Print_Box,G_Button,Selectable|Exit_Btn|Default,
- 5,5,8,2,2,$1180);
- Set_DText(Print_Box,ok_button,'OK',sf,TE_Center);
- cancel_button := Add_DItem(Print_Box,G_Button,Selectable|Exit_Btn,
- 27,5,8,2,2,$1180);
- Set_DText(Print_Box,cancel_button,'Cancel',sf,TE_Center);
- Center_Dialog(Print_Box);
- Show_It := Do_Dialog(Print_Box,0);
-
- END; {Print_Info}
-
- { dialog box for displaying the programmer and giving credits }
-
- PROCEDURE Author_Info;
-
- BEGIN
- sf := System_Font;
- Author_Box := New_Dialog(15,0,0,40,18);
- Author_Item := Add_DItem(Author_Box,G_Text,None,2,1,36,1,0,$1180);
- Set_DText(Author_Box,Author_Item,'Print Source',sf,TE_Center);
- Author_item := Add_DItem(Author_Box,G_Text,None,2,2,36,1,0,$1180);
- Set_DText(Author_Box,Author_Item,'By',sf,TE_Center);
- Author_item := Add_DItem(Author_Box,G_Text,None,2,3,36,1,0,$1180);
- Set_DText(Author_Box,Author_Item,'Daniel H. McKee',sf,TE_Center);
- Author_item := Add_DItem(Author_Box,G_Text,None,2,5,36,1,0,$1180);
- Set_DText(Author_Box,Author_Item,'Compuserve - PPN 75766,1515',
- sf,TE_Center);
- Author_item := Add_DItem(Author_Box,G_Text,None,2,6,36,1,0,$1180);
- Set_DText(Author_Box,Author_Item,'Delphi - elmac',sf,TE_Center);
- Author_item := Add_DItem(Author_Box,G_Text,None,2,8,36,1,0,$1180);
- Set_DText(Author_Box,Author_Item,'Using',sf,TE_Center);
- Author_item := Add_DItem(Author_Box,G_Text,None,2,10,36,1,0,$1180);
- Set_DText(Author_Box,Author_Item,'Personal Pascal',sf,TE_Center);
- Author_item := Add_DItem(Author_Box,G_Text,None,2,11,36,1,0,$1180);
- Set_DText(Author_Box,Author_Item,'Copyright (c) 1986 OSS & CCD',
- sf,TE_Center);
- ok_button := Add_DItem(Author_Box,G_Button,Selectable|Exit_Btn|Default,
- 15,15,8,2,2,$1180);
- Set_DText(Author_Box,ok_button,'OK',sf,TE_Center);
- Center_Dialog(Author_Box);
- Show_It := Do_Dialog(Author_Box,0);
- End_Dialog(Author_Box);
-
- END;{Author_Info}
-
- { dialog box for program instructions }
-
- PROCEDURE Do_Help;
-
- BEGIN
- sf := System_Font;
- Help_Box := New_Dialog(15,0,0,72,14);
- h_i := Add_DItem(Help_Box,G_Text,None,2,2,68,1,0,$1180);
- Set_DText(Help_Box,h_i,
- ' This program is design to print the scorce code from Personal',
- sf,TE_Left);
- h_i := Add_DItem(Help_Box,G_Text,None,2,3,68,1,0,$1180);
- Set_DText(Help_Box,h_i,
- ' Pascal Manager, but can be run from the Gem Desk Top if desired. ',
- sf,TE_Left);
- h_i := Add_DItem(Help_Box,G_Text,None,2,4,68,1,0,$1180);
- Set_DText(Help_Box,h_i,
- ' To print out your desired code, move the mouse to the menu bar',
- sf,TE_Left);
- h_i := Add_DItem(Help_Box,G_Text,None,2,5,68,1,0,$1180);
- Set_DText(Help_Box,h_i,
- ' "File" and click on the "Open File" option. The program is self-',
- sf,TE_Left);
- h_i := Add_DItem(Help_Box,G_Text,None,2,6,68,1,0,$1180);
- Set_DText(Help_Box,h_i,
- ' explanatory from this point. If you have a second disk or ram disk,',
- sf,TE_Left);
- h_i := Add_DItem(Help_Box,G_Text,None,2,7,68,1,0,$1180);
- Set_DText(Help_Box,h_i,
- ' you can change the default drive by pointing the mouse to the ',
- sf,TE_Left);
- h_i := Add_DItem(Help_Box,G_Text,None,2,8,68,1,0,$1180);
- Set_DText(Help_Box,h_i,
- ' Directory, click the mouse, backspace, type in desired path, and',
- sf,TE_Left);
- h_i := Add_DItem(Help_Box,G_Text,None,2,9,68,1,0,$1180);
- Set_DText(Help_Box,h_i,
- ' then move the mouse to the filenames, then click the mouse. Enjoy!',
- sf,TE_Left);
- ok_button := Add_DItem(Help_Box,G_Button,Selectable|Exit_Btn|Default,
- 30,11,8,2,2,$1180);
- Set_DText(Help_Box,ok_button,'OK',sf,TE_Center);
- Center_Dialog(Help_Box);
- show_it := Do_Dialog(Help_Box,0);
- End_Dialog(Help_Box);
-
- END; {Do_Help}
-
- PROCEDURE Dos_Help;
-
- BEGIN
- sf := System_Font;
- dos_box := New_Dialog(6,0,0,64,14);
- d_i := Add_DItem(dos_box,G_Text,none,2,1,14,1,0,$1180);
- Set_Dtext(dos_box,d_i,'FILE OPTIONS',sf,TE_Center);
- d_i := Add_DItem(dos_box,G_Text,none,2,3,60,1,0,$1180);
- Set_DText(dos_box,d_i,
- 'FORMAT - Select a drive, then select single or double sided.',sf,
- TE_Left);
- d_i := Add_DItem(dos_box,G_Text,none,2,5,60,1,0,$1180);
- Set_DText(dos_box,d_i,
- 'DELETE - Select a file for deleting.',sf,TE_Left);
- d_i := Add_DItem(dos_box,G_Text,none,2,7,60,1,0,$1180);
- Set_DText(dos_box,d_i,
- 'RENAME - Select file, then select a drive for renaming.',sf,TE_Left);
- d_i := Add_DItem(dos_box,G_Text,none,2,9,60,1,0,$1180);
- Set_DText(dos_box,d_i,
- 'COPY - Select file, then select a drive for copying.',sf,TE_Left);
- ok_button := Add_DItem(dos_box,G_Button,Selectable|Exit_Btn,
- 25,11,8,2,2,$1180);
- Set_DText(dos_box,ok_button,'OK',sf,TE_Center);
- Center_Dialog(dos_box);
- show_it := Do_Dialog(dos_box,0);
- End_Dialog(dos_box);
- END;{ Dos_Help }
-
-
-
-
-
- PROCEDURE Format_Dialog;
-
- BEGIN
- sf := System_Font;
- format_box := New_Dialog(5,0,0,35,9);
- f_i := Add_DItem(format_box,G_Text,none,2,1,14,1,0,$1180);
- Set_DText(format_box,f_i,'FORMAT OPTIONS',sf,TE_Center);
- ss_btn := Add_DItem(format_box,G_Button,Selectable|Radio_Btn
- ,2,3,14,1,1,$1180);
- Set_DText(format_box,ss_btn,'Single-Sided',sf,TE_Center);
- ds_btn := Add_DItem(format_box,G_Button,Selectable|Radio_Btn
- ,19,3,14,1,1,$1180);
- Set_DText(format_box,ds_btn,'Double-Sided',sf,TE_Center);
- format_btn := Add_DItem(format_box,G_Button,Selectable|Exit_Btn,
- 2,5,8,2,2,$1180);
- Set_DText(format_box,format_btn,'Format',sf,TE_Center);
- cancel_button := Add_DItem(format_box,G_Button,Selectable|Exit_Btn,
- 19,5,8,2,2,$1180);
- Set_DText(format_box,cancel_button,'cancel',sf,TE_Center);
- Obj_SetState(format_box,ss_btn,Selected,false);
- Center_Dialog(format_box);
- show_it := Do_Dialog(format_box,0);
- IF Obj_State(format_box,format_btn) <> 0 THEN
-
- Do_format
- ELSE
- End_Dialog(format_box);
- END; { Format_Dialog_Box }
-
- PROCEDURE Drive_Dialog;
-
- BEGIN
- sf := System_Font;
- drive_box := New_Dialog(5,0,0,30,9);
- d_i := Add_DItem(drive_box,G_Text,None,2,1,18,1,0,$1180);
- Set_DText(drive_box,d_i,'FORMAT WHICH DRIVE?',sf,TE_Center);
- A_btn := Add_DItem(drive_box,G_button,Selectable|Radio_Btn
- ,2,3,8,1,1,$1180);
- Set_DText(drive_box,A_btn,'A',sf,TE_Center);
- B_btn := Add_DItem(drive_box,G_button,Selectable|Radio_Btn
- ,15,3,8,1,1,$1180);
- Set_DText(drive_box,B_btn,'B',sf,TE_Center);
- ok_button := Add_DItem(drive_box,G_button,Selectable|Exit_Btn,
- 2,5,8,2,2,$1180);
- Set_DText(drive_box,ok_button,'OK',sf,TE_Center);
- cancel_button := Add_DItem(drive_box,G_button,Selectable|Exit_Btn,
- 15,5,8,2,2,$1180);
- Set_DText(drive_box,cancel_buttton,'CANCEL',sf,TE_Center);
- Obj_SetState(drive_box,A_btn,Selected,false);
- Center_Dialog(drive_box);
- show_it := Do_Dialog(drive_box,0);
- End_Dialog(drive_box);
- IF Obj_State(drive_box,ok_button) <> 0 THEN
- Format_Dialog
- ELSE;
- END; { Drive_Dialog }
-
- PROCEDURE Do_Format;
-
- VAR
- track,side,virgin,buff,disktype,execflag,spt,w,b,zero,sector,
- count,dev,interleave : integer;
- buffer,magic,serialno,filler : long_integer;
-
- BEGIN
- BEGIN
- track := 0;
- side := 0;
- buff := 1024;
- disktype := 2;
- execflag := 1;
- spt := 9;
- zero := $00;
- sector := 1;
- count := 1;
- interleave := 1;
- buffer := $3000;
- magic := $87654321;
- serialno := -1;
- END;
-
- BEGIN
- virgin := zero;
- IF Obj_State(drive_box,ds_btn) <> 0 THEN
- dev := 1
- ELSE dev := 0;
- REPEAT
- Format_Floppy(buffer,filler,dev,spt,track,side,
- interleave,magic,virgin);
- IF Obj_State(format_box,ds_btn) <> 0 THEN
- BEGIN
- virgin := $E5E5;
- side := 1;
- Format_Floppy(buffer,filler,dev,spt,track,side,
- interleave,magic,virgin);
- side := 0;
- IF track < 2 THEN
- virgin := zero;
- END;
- track := track + 1;
-
- IF track = 2 THEN
- virgin := $E5E5;
- UNTIL track = 80;
- b := Boot_Sector(buff,serialno,disktype,execflag);
- track := 0;
- w := Write_Sector(buff,filler,dev,sector,track,side,count);
- End_Dialog(format_box);
- rewrite(output,'con:');
- END;
- END; { Do_Format }
-
- PROCEDURE Error_Check;
- BEGIN
- CASE i OF
-
- -13 : choice := Do_Alert('[1][disk is write protected[ ok ]',0);
- -33 : choice := Do_Alert('[1][file not found][ ok ]',0);
-
- END;
- END; { Error_check }
-
- { to print or not to print! }
-
- PROCEDURE Print_It;
- BEGIN
- { get the dialog box }
-
- Print_Info;
- { check to see if the ok_button was selected }
- IF Obj_State(Print_Box,ok_button) <> 0 THEN
- BEGIN
- IO_Check(b);
- { set the default input from the keyboard to the disk }
- reset( INPUT, fName );
- i := IO_Result;
- Error_Check;
- IF i <> -33 THEN
- BEGIN
- { set the default output from the screen to the printer }
- REWRITE(OUTPUT,'PRN:');
- { loop for print the file until the end-of-file character }
- WHILE NOT EOF DO
- BEGIN
-
- readln(fName);
- WRITELN(fNAME);
- END;
- End_Dialog(Print_Box);
- END;
- End_Dialog(print_box);
- END;
- { check to see if the cancel_button was selected }
- IF Obj_state(Print_Box,cancel_button) <> 0 THEN
- End_Dialog(Print_Box);
-
- END; { Print_It }
-
- { this module set the path directory with the extender of '.PAS' }
-
- PROCEDURE Draw_It;
- BEGIN
- { set a default path }
- Path := 'A:\*.PAS';
- { Draw predefined dialog box for listing source files }
- IF Get_In_File(Path,fName) THEN
- Print_It
- { cancel button pressed, erase dialog box }
- ELSE ;
- END; { Draw_It }
-
- PROCEDURE Do_Delete;
-
- var
- fname : string;
- infile,i : integer;
- name : file_name_type;
-
- BEGIN
- IF Get_In_File(path,fname) THEN
- BEGIN
- D_Dialog(fname);
- IF Obj_State(delete_box,ok_button) <> 0 THEN
- BEGIN
- FOR i := 1 TO length(fname) DO
- name[i] := fname[i];
- name[length(fname) + 1] := chr(0);
- infile := Delete_File(name);
-
- END;
- END;
- END; { Do_Delete }
-
- PROCEDURE copy_file(in_file, out_file : integer);
-
- VAR
- n : long_integer;
- BEGIN
- REPEAT
- gem_close(out_file);
- out_file := gem_open(name,1);
-
- gem_seek(0,out_file,2);
- n := gem_read(in_file,chunk_size,buf);
- {writeln('reading chunk of ',n,' on input file');}
- if n < 0 then
- begin
- writeln('error ',n,' on iput file');
- halt;
- end
- else if n > 0 then
- if gem_write(out_file,n,buf ) = n then
- { writeln('wrote chunk properly') }
- else
- begin
- writeln('error writing output file');
- halt;
- end;
- UNTIL n = 0;
- END;
-
- PROCEDURE Do_Copy;
-
- var
- i : integer;
- BEGIN
- IF Get_In_File(path,fname) THEN
- BEGIN
- for i := 1 to length(fname) do
- name[i] := fname[i];
- name[length(fname) + 1] := chr(0);
-
- in_file := gem_open(name,0);
- copy_dialog;
- if Obj_State(copy_box,ok_button) <> 0 THEN
- BEGIN
- fname := filler;
- BEGIN
- i := length(fname);
- if i >8 then
- begin
- p := pos(blank,fname);
- if (p > 9) or (p = 0) then
- insert(pattern,fname,9);
- if p <> 0 then
- begin
- insert(pattern,fname,p);
- begin
- p := pos(blank,fname);
- nb := p;
- repeat
- p := pos(blank,fname);
- delete(fname,p,1);
- nb := nb + 1;
- until nb = 10;
- end;
- end;
- end;
- END;
-
- IF Obj_State(copy_box,a_btn) <> 0 THEN
- insert(a_path,fname,1)
- ELSE insert(b_path,fname,1);
- for i := 1 to length(fname) do
- name[i] := fname[i];
- name[length(fname) + 1] := chr(0);
- out_file := gem_create(name,0);
- copy_file(in_file,out_file);
- gem_close(in_file);
- gem_close(out_file);
- END;
- END;
-
- END; { Do_Copy }
-
- PROCEDURE Do_Rename;
-
- {this procedure is design generally to rename a file. However, I went }
- { a little farther to edit the file name in the dialog box so the output}
- { would look somewhat like in the desktop }
-
- const
- blank = ' ';
- pattern = '.';
-
- var
- fname : str255;
- temp,temp_name : string;
- zero,p,start,result,count,i,nb,rename_it : integer;
- name,old_name : file_name_type;
- BEGIN
- zero := 0;
- if Get_in_file(path,fname) then
- BEGIN
-
- {put the actual file name in a temporary variable}
- temp_name := fname;
- {copy the path}
- temp := copy(fname,1,3);
- {delete the path so it is not shown on the dialog box}
- Delete(fname,1,3);
- {check the length of the file, if it is 8 or less, no need}
- { to edit the file name}
- i := length(fname);
- if i > 8 then
- begin
-
- { find the pos of the period}
- p := pos(pattern,fname);
- { the period isn't is position 9? then we have}
- { to insert some blanks so the output looks good}
- { number 9 is the position where it separates }
- { first eight characters of the file name and }
- { three character extender }
- if p < 9 then
- begin
- { calculation to find how many blanks}
- { to be inserted }
- result := 9 - p;
- { position to insert the blanks }
- start := p ;
- { counter }
- count := 0;
- { insert the blank(s)! }
- repeat
- insert(blank,fname,start);
- count := count + 1;
- until count = result ;
- { find the period again }
- p := pos(pattern,fname);
- end;
- { delete the period, why? the dialog box already}
- { has a period on the editing line }
- delete(fname,p,1);
- end;
- { pass the file name to the dialog box procedure for editing }
- Rename_Dialog(fname);
- { check to see if the ok button was selected, if selected, lets take }
- { out the blanks }
- IF Obj_State(rename_box,ok_button) <> 0 THEN
- BEGIN
- { check the length again, if the file didn't have an extender, no }
- { reason to take out any blanks }
- i := length(fname);
- if i > 8 then
- begin
- p := pos(blank,fname);
- { check to see if the blanks occured after the file name }
- { if true, the file name had eight characters before the }
- { extender and at least one character extender, so the }
- { the period get inserted a the nineth position }
- iF (p > 9) or (p = 0) then insert(pattern,fname,9);
- { blank occurs before the nineth position, take out the }
- { blank(s)! }
- if p<>0 then
-
- begin
- { insert a period at the first occurancy of a }
- { blank, this is the correct position }
- insert(pattern,fname,p);
- begin
- { find the blank }
- p:= pos(blank,fname);
- nb := p;
- { repeat the process until }
- { all the blanks are deleted }
- repeat
- p:=pos(blank,fname);
- delete(fname,p,1);
- nb := nb + 1;
- until nb = 10;
- end;
- end;
- end;
- { insert the path back into the file name }
- insert(temp,fname,1);
- { thanks to OSS for this routine! }
- BEGIN
- FOR i := 1 TO length(fname) DO
- name[i] := fname[i];
- { add zero to the end, 'C' needs it }
- name[length(fname) + 1] := chr(0);
- END;
-
- BEGIN
-
- FOR i := 1 TO length(temp_name) DO
- old_name[i] := temp_name[i];
- old_name[length(temp_name) + 1] := chr(0);
- END;
- {all finished, take old name and new name to renaming function}
- rename_it := Rename_File(zero,old_name,name);
-
- END;
- END;
- END; { Do_Rename, Whew!!! }
-
-
- { this module checks the menu bar for the option selected }
-
- PROCEDURE Do_menu(title,item : integer);
-
- BEGIN
- BEGIN
- IF title = three THEN
- Author_Info
- ELSE IF item = open_item THEN
- Draw_it
- ELSE IF item = help_item THEN
- Do_Help
- ELSE IF item = dos_item THEN
- Dos_Help
- ELSE IF item = format_item THEN
- Drive_Dialog
- ELSE IF item = delete_item THEN
- Do_Delete
-
- ELSE IF item = rename_item THEN
- Do_Rename
- ELSE IF item = copy_item THEN
- Do_Copy
- ELSE IF item = quit_item THEN
- END;
- Menu_Normal(menu,title);
- END; { Do_Menu }
-
- { loop for getting a message }
-
- PROCEDURE Event_Loop;
- VAR
- which : integer;
- msg : Message_Buffer;
-
- BEGIN
- REPEAT
-
- which := Get_Event(E_Message,0,0,0,0,false,0,0,0,0,false,
- 0,0,0,0,msg,dummy,dummy,dummy,dummy,
- dummy,dummy);
- Do_Menu( Msg[3], Msg[4]);
- UNTIL msg[4] = quit_item;
- END; { Event_Loop }
-
- PROCEDURE New_Menu_Bar;
-
- BEGIN
- menu := New_Menu( 6, ' file printer ' );
- file_title := Add_MTitle( menu, ' File ' );
- Help_title := Add_MTitle( menu, ' Help ' );
- open_item := Add_MItem ( menu, file_title, ' Print File ' );
- help_item := Add_MItem ( menu, help_title, ' Print Info ');
- dos_item := Add_MItem ( menu, help_title, ' File Info ');
- format_item := Add_MItem(menu,file_title, ' Format ');
- delete_item := Add_MItem( menu, file_title,' Delete ');
- rename_item := Add_MItem( menu, file_title,' Rename ');
- copy_item := Add_MItem( menu, file_title, ' Copy ');
- quit_item := Add_MItem ( menu, file_title, ' Quit ');
- Draw_Menu( menu );
- END;
-
- BEGIN { Main Program }
- IF Init_Gem >= 0 THEN
- BEGIN
- Init_Mouse;
- path := 'A:\.PAS';
- New_Menu_Bar;
- Event_Loop;
- Erase_Menu ( menu);
- Exit_Gem;
- END
-
- END. { Main }
-